package org.sixdog.mcsit.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")                  //域访问的路径
//                .allowedOrigins("106.12.155.7:80")            //允许的起源
            .allowedOriginPatterns("*") // 允许所有域
            .allowedHeaders(CorsConfiguration.ALL)      //头
            .allowedMethods(CorsConfiguration.ALL)     //请求方法post,get等
            .allowCredentials(true)             //是否携带一些信息，例如token
            .maxAge(3600);              //xxx最大响应时间xxx
    }
}
